<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="header::header" />
<body>

   <table style="border: 1px;width: 300px;height: 400px;text-align: center;" >
       <!--   <tr >
         	<td style=" width: 100px;">用户id:</td>
          	<td><input  th:value="${userVO.iid}" class="easyui-textbox"></input></td>
         </tr> -->
		<tr>
         	<td>用户名:</td>
          	<td><label><a id="cname"></a></label></td>
         </tr>
          <tr>
         	<td>手机号码:</td>
          	<td><label><a id="mobile"></a></label></td>
         </tr>
        
         <tr>
         	<td>用户邮箱:</td>
          	<td><label><a id="email"></a></label></td>
         </tr>
       <tr>
         	<td colspan="2"><input type="button" value="修改密码" onclick="show()"></input></td>
         </tr>
   </table>
	<div id="dlg-query" class="easyui-dialog" title="修改密码" style="padding: 5px" data-options="buttons: '#dlg-query-buttons',closed:'true',modal:true">
		<form id="dataform-query" method="post">
			<table>
				<tr>
					<td>新密码:</td>
					<td><input id="newpwd" type="password"  style="width: 200px" /></td>
				</tr>
				<tr>
					<td>确认密码:</td>
					<td><input id="checknewpwd" type="password"  style="width: 200px" ></input></td>
				</tr>
				
			</table>
		</form>
	</div>
	<div id="dlg-query-buttons">
		<a id="dlg-query-savebtn1" href="javascript:void(0)" style="width: 50" class="easyui-linkbutton" iconCls="icon-search" onclick="updatePwd()" >修改</a>
		<a id="dlg-query-closebtn1"  style="width: 50" class="easyui-linkbutton" iconCls="icon-no" onclick="close()">取消</a>
	</div>

</body>
<script type="text/javascript" th:src="@{/common/GridView.js}"></script>
<script th:inline="javascript">
$(document).ready(function() {
var cname=/*[[${cname}]]*/
var mobile= /*[[${userVO.cmobile}]]*/
var email = /*[[${userVO.cemail}]]*/
$("#cname").html(cname);
$("#mobile").html(mobile)
$("#email").html(email)
})

  function show(){
  $("#dlg-query").dialog("open");
  
  }
  
  function close(){
  $("#dlg-query").dialog("close");
  
  }
  
	function updatePwd(){
	var newPwd=$("#newpwd").val();
	var checknewPwd=$("#checknewpwd").val();
	if(newPwd.length==0){
	$.messager.alert("提示", "请输入新密码");
	return;
	}
	if(checknewPwd.length==0){
	$.messager.alert("提示", "请确认密码");
	return;
	}
	if(newPwd!=checknewPwd){
	$.messager.alert("提示", "两次密码输入不一致");
	return;
	}
	  $.ajax({
                    type : "post",
                    url : "../user/updatePwd",
                    data : {
                        newPwd:newPwd
                    },
                     success : function(data) {
                     if(data.success){
                     $.messager.alert("提示", data.msg,"info",function(){
                     		 window.parent.location.href= "../login/index";
                     });
                    	
                     }else{
                     	$.messager.alert("提示", data.msg);
                     }
                     }
                     
                      });
	}
</script>
</html>